
import log from 'loglevel';
import createjs from 'createjs-npm' 

let canvas_id = "game";
log.info("init createjs stage from canvas_id=%s", canvas_id)
let stage = new createjs.Stage(canvas_id)
log.info("stage=", stage)

// 创建矩形形状
var rect = new createjs.Shape();
rect.graphics.beginFill("#000000").drawRect(0, 0, stage.canvas.width, stage.canvas.height);
// 将矩形添加到舞台
stage.addChild(rect);

// 启动帧循环
createjs.Ticker.addEventListener('tick', on_frame_tick);
function on_frame_tick(evnet) { // eslint-disable-line @typescript-eslint/no-unused-vars
    stage.update();
}


function main() {
    log.info("start main")
    // 创建一个精灵表（SpriteSheet）
    let spriteSheet = new createjs.SpriteSheet({
        images: ["assets/bos_wars/units/tank/unit_tank.png"], // 图像路径
        frames: { width: 102, height: 111, count: 1 }, // 每帧的宽度和高度，以及帧数
        animations: {
            // 定义一个包含整张图的动画
            fullImage: [0, 1, "fullImage"]
        }
    });

    var sprite = new createjs.Sprite(spriteSheet, "fullImage");
    stage.addChild(sprite)
}

main();